var util = require('../../utils/util.js');
var api = require('../../config/api.js');


var app = getApp();

Page({
  data: {
    id: 0,
    articleTitle:'',
    articleDesc:'',
    articleContent:'',
    createTime:'',
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    var that = this;
    that.setData({
      id: parseInt(options.id)
    });
    this.getDetail();
  },
  getDetail: function () {
    let that = this;
    util.request(api.ArticleInfo+'/'+that.data.id, {},'get').then(function (res) {
      if (res.errno === 0) {
        that.setData({
          articleTitle:res.data.articleTitle,
          articleDesc:res.data.articleDesc,
          articleContent:res.data.articleContent.replaceAll('<img ', '<img style="max-width:100%;height:auto;display:block;margin:10px 0;"'),
          createTime:res.data.createTime,
 

        });         
      }
    });
  }, 
  onReady: function () {
    // 页面渲染完成

  },
  onShow: function () {
    // 页面显示

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭

  }
})